// 创建自定义视频 Blot 类
import Quill from "quill";

const BlockEmbed = Quill.import("blots/block/embed");

class VideoBlot extends BlockEmbed {
    static create(value) {
        const node = super.create();
        node.setAttribute("src", value.url);
        node.setAttribute("controls", "controls");
        node.setAttribute(
            "style",
            `width: ${value.width || "100%"}; height: ${value.height || "auto"}`,
        );
        return node;
    }

    static value(node) {
        return {
            url: node.getAttribute("src"),
            width: node.style.width,
            height: node.style.height,
        };
    }
}

VideoBlot.blotName = "customVideo";
VideoBlot.tagName = "video";
Quill.register(VideoBlot);
